Getting Values into a Program

You can choose from several methods to supply the values that a function or program uses in calculations.

Embedding the Values Within the Program or Function

This method is useful primarily for values that must be the same each time the program or function is used.

1. Define the program.

2. Run the program.

Letting the User Assign the Values to Variables

A program or function can refer to variables created beforehand. This method requires users to remember the variable names and to assign values to them before using the object.

1. Define the program.

2. Supply the variables, and then run the program.

Letting the User Supply the Values as Arguments

This method lets users pass one or more values as arguments within the expression that calls the program or function.

The following program, volcyl, calculates the volume of a cylinder. It requires the user to supply two values: height and radius of the cylinder.

1. Define the volcyl program.

2. Run the program to display the volume of a cylinder with a height of 34 mm and a radius of 5 mm.

Note: You do not have to use the parameter names when you run the volcyl program, but you must supply two arguments (as values, variables, or expressions). The first must represent the height, and the second must represent the radius.

Requesting the Values from the User (Programs Only)

You can use the Request and RequestStr commands in a program to make the program pause and display a dialog box prompting the user for information. This method does not require users to remember variable names or the order in which they are needed.

You cannot use the Request or RequestStr command in a function.

1. Define the program.

2. Run the program and respond to the requests.

Use RequestStr instead of Request when you want the program to interpret the user’s response as a character string rather than a math expression. This avoids requiring the user to enclose the response in quotation marks (““).